<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>创建组件</h2>
      <tb-header></tb-header>
      <tb-content></tb-content>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      // 局部创建组件
      const TbHeader = {
        // 对象里面可以写所有的选项,必须要包含一个template(模板)
        data() {
          return {
            count: 123,
          };
        },
        template: "<header>淘宝头部 - {{ count }}</header>",
      };

      const TbContent = {
        template: "<main>淘宝内容</main>",
      };

      // createApp生成的叫根组件
      createApp({
        data() {
          return {};
        },
        // 组件注册
        components: {
          TbHeader: TbHeader,
          TbContent,
        },
      }).mount("#app");
    </script>
  </body>
</html>
